<?php
    if($_POST['name']){
    mysql_connect('localhost','root','')or
        die('could not connect'.mysql_error());
    mysql_query('set names utf8');
    mysql_select_db('blog');
    $sql="INSERT INTO comment (`post_id` ,`name` ,`email` ,`site`,`message` ,`times`)
    VALUES ('".$_GET['id']."', '".$_POST['name']."','".$_POST['email']."','".$_POST['site']."','".nl2br($_POST['message'])."',".time().")";
    mysql_query($sql);
    }
?>
<h2>发表评论：</h2>
<div id="comment">
    <form method="post" action="">
       <input type="hidden" name="pid" value="<?php echo $_GET['id']?>">
       <br /><input type="text" name="name" size="30">你的称呼<br />
       <br /><input type="text" name="email" size="30">你常用的邮箱<br />
       <br /><input type="text" name="site" size="30">你的主页或博客地址<br />
       <br /><textarea name="message" rows="8" cols="80"></textarea><br />
       <button type="submit">提交</button>
    </form>
</div>
